﻿<%@ Page Language="VB" AutoEventWireup="false" %>
<%@ import namespace="Boogaloo.Core.BLL" %>
<%@ import namespace="Boogaloo.Core.UI" %>
<script runat="server">

	Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load        
        hyp_admin.NavigateUrl = Groove.path_admin
        
        If Groove.site_root Is Nothing Then
                            
            Dim root_id As Integer = Root.InsertRoot("Boogaloo", "Development Boogaloo Website", admin_initial_root:=True)
            Dim domain_id As Integer = Domain.InsertDomain(root_id, Request.ServerVariables("SERVER_NAME"), True)

            

            If Not Roles.GetAllRoles().Contains("Boogaloo Admin") Then Roles.CreateRole("Boogaloo Admin")
              
        
            ' configure add the first master page
            Dim r As Root = Root.GetRoot(root_id)
            Dim master_page_id As Integer = MasterTemplate.InsertMasterTemplate("base.master", "~/Masters/Default/base.master", root_id)
        
            ' create the initial layout
            InsertLayout(r, master_page_id)
        
        
            ' insert the default controls
            RegisteredControl.InsertControl(0, r.root_id, "Html Source Editor", "~/Controls/HtmlSource/HtmlSource.ascx", "~/Controls/HtmlSource/HtmlSourceEditor.ascx", True)
            RegisteredControl.InsertControl(0, r.root_id, "Listing Editor", "~/Controls/Listing/Listing.ascx", "~/Controls/Listing/ListingEditor.ascx", True)
        
            CreateAdminUser()
            
        End If
        
    End Sub
    
    
    Private Sub InsertLayout(ByVal r As Root, ByVal master_page_id As Integer)
        

        Dim component_id As Integer = 0
        Dim child_component_id As Integer = 0
        
        component_id = CType(Boogaloo.Base.Globals.Settings.Components("Core").component_id, Integer)
        child_component_id = component_id
        
        Dim CREATE_DEFAULT_PAGE As Boolean = r.HasNodeCreationRequirements() And Not r.HasLayoutNodes()

        ' insert the layout
        Dim node_id As Integer = Node.InsertNode(0, r.root_id, NodeType.WebPage, component_id, master_page_id, Nothing, _
                child_component_id, 8, 0, "Root pages", _
                Nothing, "Root pages", Nothing, Nothing, Nothing, Nothing, String.Format("Layout: {0}", "Root pages"), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, _
                Nothing, Nothing, Nothing, False, True, True, False, True, False, Nothing)

        If CREATE_DEFAULT_PAGE Then
            ' special case in which this host does not have a default page or layout to spawn additional pages

            ' Create the default homepage
            Dim default_node_id As Integer = Node.InsertNode(0, r.root_id, NodeType.WebPage, component_id, master_page_id, node_id, _
                child_component_id, 8, 0, "Home", Nothing, _
                "Home", Nothing, Nothing, Nothing, Nothing, "Home", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, DateTime.Today, Nothing, _
                Nothing, Nothing, True, True, True, False, False, False, String.Empty)

            ' Create the default publish record
            Dim publish_id As Integer = Publish.InsertPublish(r.root_id, DateTime.Now, "c")

            
            r.child_layout_node_id = node_id
            r.default_node_id = default_node_id
            r.Update()

        End If

        ' set the root layout if needed      
        r.child_layout_node_id = node_id
        r.Update()

    End Sub
    
    
    Private Sub CreateAdminUser()
        If Membership.GetUser("Admin") Is Nothing Then
            Dim user As MembershipUser = Membership.CreateUser("Admin", "admin")
            Dim users As String() = {"Admin"}
            Roles.AddUsersToRole(users, "Boogaloo Admin")
        End If
    End Sub

</script>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <link rel="stylesheet" type="text/css" runat="server" href="~/App_Themes/boogaloo/a_boogaloo_reset.css" />
    <link rel="stylesheet" type="text/css" runat="server" href="~/App_Themes/boogaloo/b_boogaloo_extensions.css" />
    <link rel="stylesheet" type="text/css" runat="server" href="~/App_Themes/boogaloo/c_layout.css" />
    <link rel="stylesheet" type="text/css" runat="server" href="~/App_Themes/boogaloo/d_type.css" />
    <link rel="stylesheet" type="text/css" runat="server" href="~/App_Themes/boogaloo/e_color.css" />
    <link rel="stylesheet" type="text/css" runat="server" href="~/App_Themes/boogaloo/f_extensions.css" />
    <link rel="stylesheet" type="text/css" runat="server" href="~/App_Themes/boogaloo/g_print.css" media="print" />
    <link rel="stylesheet" type="text/css" runat="server" href="~/App_Themes/boogaloo/h_mobile.css" media="mobile" />
    <!--[if lt IE 8]>
    <link rel="stylesheet" type="text/css" runat="server" href="~/App_Themes/boogaloo/i_ie.css" />
    <![endif]-->
    <!--[if lt IE 7]>
    <link rel="stylesheet" type="text/css" runat="server" href="~/App_Themes/boogaloo/j_ie6.css" />
    <![endif]-->

</head>
<body>
    <form id="form1" runat="server">
    <div id="content"><div class="section main">
     <h1>Please remember!</h1>
    <ul>
        <li><h2><em>Remove</em> this /Install Folder</h2></li>
        <li><h2><em>Change</em> the "admin" password</h2>
        <p>Current Admin username/password is : admin / admin</p>       
        </li>
    </ul>
    <p><em>If running locally, edit the tiny_mce script page in the web.config (line 40) to reflect your local directory.</em></p>
    <p><asp:hyperlink id="hyp_admin" runat="server" cssclass="button" text="Proceed to Boogaloo Administration" /></p>
    </div></div>
    </form>
</body>
</html>
